<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改论文')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-thesis-edit" th:object="${ycThesis}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">序号：</label>
                <div class="col-sm-8">
                    <input name="serialNumber" th:field="*{serialNumber}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">期刊名称：</label>
                <div class="col-sm-8">
                    <input name="journalName" th:field="*{journalName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">CN/ISSN：</label>
                <div class="col-sm-8">
                    <input name="cnIssn" th:field="*{cnIssn}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">期刊类别(红色为默认)：</label>
                <div class="col-sm-8">
                    <select id="journalCategories" name="journalCategories"  th:field="*{journalCategories}" class="form-control" type="text" ></select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">论文名称：</label>
                <div class="col-sm-8">
                    <input name="paperTitle" th:field="*{paperTitle}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">第一作者：</label>
                <div class="col-sm-8">
                    <input name="firstAuthor" th:field="*{firstAuthor}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">发表时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="postedTime" th:value="${#dates.format(ycThesis.postedTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">位次：</label>
                <div class="col-sm-8">
                    <input name="precedence" th:field="*{precedence}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">赋分：</label>
                <div class="col-sm-8">
                    <input name="assignPoints" th:field="*{assignPoints}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">奖励：</label>
                <div class="col-sm-8">
                    <input name="award" th:field="*{award}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">备案：</label>
                <div class="col-sm-8">
                    <input name="onRecords" th:field="*{onRecords}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">上传人：</label>
                <div class="col-sm-8">
                    <input name="proposer" th:field="*{proposer}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">上传文件：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="filesUpload" th:field="*{filesUpload}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="filesUpload" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">审批：</label>
                <div class="col-sm-8">
                    <input name="status" th:field="*{status}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "ruoyi/thesis";
        $("#form-thesis-edit").validate({
            focusCleanup: true
        });
        a()
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-thesis-edit').serialize());
            }
        }

        $("input[name='postedTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function a() {
            var a =[[${ycThesis.journalCategories}]]
            $.ajax({
                url: prefix + "/score",
                type: "get",
                dataType:"json",
                data: {},
                success: function(data){
                    if(data.length>0){
                        //红色代表默认选中
                        $("#journalCategories").append("<option style='color:red'>"+ a +"</option>")
                        for(i in data){
                            $("#journalCategories").append("<option>"+data[i].journalCategories+"</option>")
                        }
                    }else{
                        $("#journalCategories").append("<option>暂无数据</option>")
                    }
                },
            })}

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': '/common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>
</body>
</html>